<?php
/*
 * 新锐手机注册 [ 深圳市新锐创意科技有限公司旗下产品 ]
 * Copyright  2015-2099 www.xinruiweb.com  All Rights Reserved.
 * 技术开发: 75674952@qq.com
 * 请支持正版授权产品
 */
if (!defined('IN_DISCUZ')) {
	exit('Access Denied');
}
require_once DISCUZ_ROOT.'./source/plugin/xinrui_qq/class/fun.class.php';

session_start();
class plugin_xinrui_qq_base{
    function common_base() {
        global $_G;
        loadcache(array('plugin'));
        if($_G['uid']) {
			$_G['xr_qq'] = C::t('#xinrui_qq#xinrui_qq_user')->fetch_first_by_uid($_G['uid']);
		}
        if(isset($_SESSION['xinrui_login_uid']) && $_SESSION['xinrui_login_uid'] > 0){
            $login = XR_QQ::login($_SESSION['xinrui_login_uid']);
            if($login) {
                loaducenter();
                $ucsynlogin = uc_user_synlogin($_SESSION['xinrui_login_uid']);
                echo $ucsynlogin ;
            }
            unset($_SESSION['xinrui_login_uid']);
        }
    }
}

class plugin_xinrui_qq extends plugin_xinrui_qq_base {

        function plugin_xinrui_qq() {
        //error_reporting(E_ALL);
        global $_G;
		include_once template('xinrui_qq:module');

	}

    function common() {
        global $_G;
        $this->common_base();
	}

    function global_login_extra() {
        global $_G;
        if($_G['uid']){
            return array();
        }
		return xinrui_qq_tpl_login_extra_bar(false);
	}

    function global_login_text() {
        global $_G;
        if($_G['uid']){
            return array();
        }
        return xinrui_qq_tpl_login_extra_bar(true);
    }

    function global_usernav_extra1() {
		global $_G;
        if(!$_G['uid']){
            return array();
        }
        
		return xinrui_qq_tpl_setting();
	}

    function global_footer(){
        global $_G;
        if(!$_G['uid']){
            return array();
        }

		return xinrui_qq_tpl_setting_menu();
    }

}


class plugin_xinrui_qq_member extends plugin_xinrui_qq {

	function logging_member_message() {
		global $_G;
	}

    function logging_method() {
        global $_G;
        if($_G['uid']) {
            return;
        }
        return xinrui_qq_tpl_login_bar();
    }

    function register_logging_method() {
		global $_G;
		if($_G['uid']) {
            return;
        }
		return xinrui_qq_tpl_login_bar();
	}

}


class mobileplugin_xinrui_qq extends plugin_xinrui_qq_base {
    function common() {
		global $_G;
        $this->common_base();

        if($_G['xr_qq'] && defined('IN_MOBILE') && $_GET['mod'] == 'login' && empty($_GET['op'])){
            //dheader('Location:/');
        }
        include_once template('xinrui_qq:module');


    }

    function global_header_mobile() {
		global $_G;
        if(CURMODULE == 'space' && $_GET['do'] == 'profile' && $_G['uid']){
            return "<script>
$(function(){
	$(document).on('click','.xinrui_qq_menu',function(){
		$.post($(this).attr('data-url'), {inajax: 1}, function(s) {
			popup.open(s.lastChild.firstChild.nodeValue);
			//myArray[wq_id] = s.lastChild.firstChild.nodeValue;
		}, 'xml');
	})	
})
</script>";
        }
	}


    function global_footer_mobile() {
        global $_G;
        if(CURMODULE == 'space' && $_GET['do'] == 'profile' && $_G['uid'] == $_GET['uid']){
            if(empty($_G['xr_qq'])){  
                return qq_home_space_profile_bind();
            }else if($_G['xr_qq']['uid'] == $_G['xr_qq']['bind']){
                return qq_home_space_profile_my();
            }
        }
	}

}

class mobileplugin_xinrui_qq_member extends mobileplugin_xinrui_qq {
    function logging_bottom_mobile() {
		global $_G;
		return tpl_login_bottom_qq();
    }
}

?>
